package com.zjb.demo.system.controller;

import com.zjb.demo.common.domain.response.AjaxResult;
import com.zjb.demo.system.domain.CommonBizFile;
import com.zjb.demo.system.service.CommonBizFileService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.noear.solon.annotation.*;

import java.util.List;

/**
 * 业务文件 接口
 *
 * @author 庄佳彬
 * @since 2023/12/27 13:12
 */
@Controller
@Api(tags = "业务文件")
@Mapping("/common-biz-file")
public class CommonBizFileController {
    @Inject
    private CommonBizFileService service;

    @ApiOperation(value = "查询附件信息")
    @Get
    @Mapping("/selectByMainIdAndBizType")
    public AjaxResult<List<CommonBizFile>> selectByMainIdAndBizType(Long mainId, String bizType) {
        return AjaxResult.success(service.selectByMainIdAndBizType(mainId, bizType));
    }

    @ApiOperation(value = "删除附件")
    @Delete
    @Mapping("/deleteByMainIdAndBizType")
    public AjaxResult<Boolean> deleteByMainIdAndBizType(Long mainId, String bizType) {
        return AjaxResult.success(service.deleteByMainIdAndBizType(mainId, bizType));
    }

    @ApiOperation(value = "存储附件信息")
    @Post
    @Mapping("/save")
    public AjaxResult<Boolean> save(List<CommonBizFile> file) {
        return AjaxResult.success(service.saveBatch(file));
    }

}
